package tool

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

type ResponseData struct {
	Code int         `json:"code,omitempty"`
	Msg  string      `json:"msg,omitempty"`
	Data interface{} `json:"data,omitempty"`
}

func Error(c *gin.Context, msg string) {
	rd := &ResponseData{
		Code: 10001,
		Msg:  msg,
		Data: nil,
	}

	c.JSON(http.StatusOK, rd)
}

func Success(c *gin.Context, msg string, data interface{}) {
	rd := &ResponseData{
		Code: 20000,
		Msg:  msg,
		Data: data,
	}
	c.JSON(http.StatusOK, rd)
}
